home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / progsrc / impact21 / mouse.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-27  |  1.2 KB  |  55 lines

  1. /*
  2.    This provides functions for polling the mouse.  The main routine,
  3.    mouse, has this description.
  4.  
  5.    To do various functions (input) [output] set 'a' to
  6.     0 - test if loaded [reg.ax = $ffff]
  7.     1 - show cursor
  8.     2 - hide cursor
  9.     3 - get position [b buttons, c x, d y]
  10.     4 - set position (c x,d y)
  11.     5 - press button   (b buttons, c x, d y) [b count]
  12.     6 - release button (b buttons, c x, d y) [b count]
  13.     7 - set x range  (c min, d max)
  14.     8 - set y range  (c min, d max)
  15.     10- text cursor  (b 0=soft 1=hard, c ?, d ?)
  16.     15- mickeys      (c xscale, d yscale?)
  17. */
  18.  
  19. #define MOUSEINT 0x33
  20. #include <dos.h>
  21.  
  22. int mouse(int a,int *b,int *c,int *d)
  23. {
  24.   static union REGS regs;
  25.   regs.x.ax = a;
  26.   regs.x.bx = *b;
  27.   regs.x.cx = *c;
  28.   regs.x.dx = *d;
  29.   int86(MOUSEINT,®s,®s);
  30.   *b = regs.x.bx;
  31.   *c = regs.x.cx;
  32.   *d = regs.x.dx;
  33.   return regs.x.ax;
  34. }
  35.  
  36. int init_mouse() {
  37.   int x=0; return mouse(0,&x,&x,&x);
  38. }
  39.  
  40. int show_mouse() {
  41.   int b=0; return mouse(1,&b,&b,&b);
  42. }
  43.  
  44. int hide_mouse() {
  45.   int b=0; return mouse(2,&b,&b,&b);
  46. }
  47.  
  48. int get_mouse(int *x,int *y) {
  49.   int b=0; mouse(3,&b,x,y); return b;
  50. }
  51.  
  52. int set_mouse(int x,int y) {
  53.   int b=0; return mouse(4,&b,&x,&y);
  54. }
  55.